package com.hangwei.paperless.presenter;

import com.hangwei.paperless.model.bean.AcceptCheckInfo;
import com.hangwei.paperless.model.bean.BasicInfoBean;
import com.hangwei.paperless.model.bean.CardToSeal;
import com.hangwei.paperless.model.bean.DRSInfo;
import com.hangwei.paperless.model.bean.DataFilling;
import com.hangwei.paperless.model.bean.DictBean;
import com.hangwei.paperless.model.bean.Disposition;
import com.hangwei.paperless.model.bean.EngTreatmentInfo;
import com.hangwei.paperless.model.bean.Login;
import com.hangwei.paperless.model.bean.LotDataSheet;
import com.hangwei.paperless.model.bean.MainRepairList;
import com.hangwei.paperless.model.bean.PartCheckInfo;
import com.hangwei.paperless.model.bean.PartsRoutingSheet;
import com.hangwei.paperless.model.bean.QRBean;
import com.hangwei.paperless.model.bean.RecordListBean;
import com.hangwei.paperless.model.bean.ResultBean;
import com.hangwei.paperless.model.bean.ServerVersion;
import com.hangwei.paperless.model.bean.Sheet;
import com.hangwei.paperless.model.bean.SheetType;
import com.hangwei.paperless.model.bean.SubPartCheckSealBean;
import com.hangwei.paperless.model.bean.SubProcessInfo;
import com.hangwei.paperless.model.bean.SubProcessListAll;
import com.hangwei.paperless.model.bean.SubSetInfo;
import com.hangwei.paperless.model.bean.SubSetListSealBean;
import com.hangwei.paperless.model.bean.TokenInfo;
import com.hangwei.paperless.model.bean.UserInfo;
import com.hangwei.paperless.net.NetManager;
import com.twelve.all.net.CallBack;
import com.twelve.all.net.ResponseInfo;
import com.twelve.all.presenter.BasePresenter;
import com.twelve.all.utils.SPKey;
import com.twelve.all.utils.SPUtil;

import java.util.ArrayList;
import java.util.List;

import okhttp3.RequestBody;
import rx.Observable;

/**
 * Created by 张龙臣 on 2020/10/23.
 */

public class StaticPresenter extends BasePresenter {

    public static void doLoginPad(final String userName, final String password, CallBack<Login> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Login>(callBack) {
            @Override
            protected Observable<ResponseInfo<Login>> getObservable() {
                return NetManager.getResponseInfoAPI().doLoginPad(userName, password, "pad.workshop");
            }
        });
    }

    public static void doLoginPadByCard(String msg, CallBack<Login> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Login>(callBack) {
            @Override
            protected Observable<ResponseInfo<Login>> getObservable() {
                return NetManager.getResponseInfoAPI().doLoginPadByCard(msg,"pad.workshop");
            }
        });
    }

    public static void getToken(final String appid, final long timestamp, final String nonce, final String sign, CallBack<TokenInfo> tokenInfoCallBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<TokenInfo>(tokenInfoCallBack) {
            @Override
            protected Observable<ResponseInfo<TokenInfo>> getObservable() {
                return NetManager.getResponseInfoAPI().getToken(appid, timestamp, nonce, sign);
            }
        });
    }

    public static void getUserInfo(final String userId, CallBack<UserInfo> userInfoCallBack) {
        final String clientid = SPUtil.getString(SPKey.clientid);
        NetManager.getInstance().doSubscribe(new NetManager.Model<UserInfo>(userInfoCallBack) {
            @Override
            protected Observable<ResponseInfo<UserInfo>> getObservable() {
                return NetManager.getResponseInfoAPI().getUserInfo(userId, clientid, "pad.workshop");
            }
        });
    }

    public static void getAllTaskList(final String userId, final String sheetTypeId, final String isForInspection, CallBack<List<Sheet>> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<List<Sheet>>(callBack) {
            @Override
            protected Observable<ResponseInfo<List<Sheet>>> getObservable() {
                return NetManager.getResponseInfoAPI().getAllTaskList(userId, sheetTypeId, isForInspection);
            }
        });
    }

    public static void getRoutingSheetByKeyword(final String userId, final String sheetTypeId, final String keywords, CallBack<List<Sheet>> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<List<Sheet>>(callBack) {
            @Override
            protected Observable<ResponseInfo<List<Sheet>>> getObservable() {
                return NetManager.getResponseInfoAPI().getRoutingSheetByKeyword(userId, sheetTypeId, keywords);
            }
        });
    }

    public static void getRoutingSheetByQRCode(String userId, String result, CallBack<QRBean> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<QRBean>(callBack) {
            @Override
            protected Observable<ResponseInfo<QRBean>> getObservable() {
                return NetManager.getResponseInfoAPI().getRoutingSheetByQRCode(userId,result);
            }
        });
    }

    public static void getRoutingSheetInfo(final String userId, final String billId, CallBack<BasicInfoBean> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<BasicInfoBean>(callBack) {
            @Override
            protected Observable<ResponseInfo<BasicInfoBean>> getObservable() {
                return NetManager.getResponseInfoAPI().getRoutingSheetInfo(userId, billId);
            }
        });
    }

    public static void getSheetTypeList(final String userId, CallBack<List<SheetType>> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<List<SheetType>>(callBack) {
            @Override
            protected Observable<ResponseInfo<List<SheetType>>> getObservable() {
                return NetManager.getResponseInfoAPI().getSheetTypeList(userId);
            }
        });
    }

    public static void getRoutingSheetList(final String userId, final String billId, CallBack<SubProcessInfo> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<SubProcessInfo>(callBack) {
            @Override
            protected Observable<ResponseInfo<SubProcessInfo>> getObservable() {
                return NetManager.getResponseInfoAPI().getRoutingSheetList(userId, billId);
            }
        });
    }

    public static void getReceiveRecordSheet(final String userId, final String billId, CallBack<AcceptCheckInfo> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<AcceptCheckInfo>(callBack) {
            @Override
            protected Observable<ResponseInfo<AcceptCheckInfo>> getObservable() {
                return NetManager.getResponseInfoAPI().getReceiveRecordSheet(userId, billId);
            }
        });
    }

//    public static void getRoutingSheetStep(final String userId, final String billId, final int billSeq, final int scope, CallBack<MainRepairList> callBack) {
//        NetManager.getInstance().doSubscribe(new NetManager.Model<MainRepairList>(callBack) {
//            @Override
//            protected Observable<ResponseInfo<MainRepairList>> getObservable() {
//                return NetManager.getResponseInfoAPI().getRoutingSheetStep(userId, billId, billSeq, scope);
//            }
//        });
//    }

    public static void getExRoutingSheetSteps(final String userId, final String billId, CallBack<List<RecordListBean>> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<List<RecordListBean>>(callBack) {
            @Override
            protected Observable<ResponseInfo<List<RecordListBean>>> getObservable() {
                return NetManager.getResponseInfoAPI().getExRoutingSheetSteps(userId,billId);
            }
        });
    }

    public static void stampRoutingSheetContent(final String userId, final String billId, final int billSeq,
                                                final String stampRole, final String stampUserId, final String stampId, final String remark, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().stampRoutingSheetContent(userId, billId, billSeq, stampRole, stampUserId, stampId, remark);
            }
        });
    }

    public static void saveReceiveRecordSheet(final RequestBody requestBody, CallBack<List<AcceptCheckInfo.TBean>> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<List<AcceptCheckInfo.TBean>>(callBack) {
            @Override
            protected Observable<ResponseInfo<List<AcceptCheckInfo.TBean>>> getObservable() {
                return NetManager.getResponseInfoAPI().saveReceiveRecordSheet(requestBody);
            }
        });
    }

    public static void removeReceiveRecordSheetRow(final String userId, final String id, CallBack<Object> objectCallBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(objectCallBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().removeReceiveRecordSheetRow(userId, id);
            }
        });
    }

    public static void stampRoutingSheetStep(final String userId, final String billId, final String stepId, final int stampRole, final String stampUserId, final String stampId, final String resultVal, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().stampRoutingSheetStep(userId, billId, stepId, stampRole, stampUserId, stampId, resultVal);
            }
        });
    }

    public static void getDrsAndAttachmentList(final String userId, final String stepId, final int scope, CallBack<DRSInfo> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<DRSInfo>(callBack) {
            @Override
            protected Observable<ResponseInfo<DRSInfo>> getObservable() {
                return NetManager.getResponseInfoAPI().getDrsAndAttachmentList(userId, stepId, scope);
            }
        });
    }

    public static void saveStepDrs(final RequestBody requestBody, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().saveStepDrs(requestBody);
            }
        });
    }

    public static void saveRoutingSheetListInfo(final String userId, final String billId, final String id, final String pn, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().saveRoutingSheetListInfo(userId, billId, id, pn);
            }
        });
    }

    public static void getDictByIdOrCode(final String userId, final String id, final String naType, final int pagenumber, final int pagesize, CallBack<List<DictBean>> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<List<DictBean>>(callBack) {
            @Override
            protected Observable<ResponseInfo<List<DictBean>>> getObservable() {
                return NetManager.getResponseInfoAPI().getDictByIdOrCode(userId, id, naType, pagenumber, pagesize);
            }
        });
    }

    public static void getResultDetailList(final String userId, final String resultId, CallBack<List<ResultBean>> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<List<ResultBean>>(callBack) {
            @Override
            protected Observable<ResponseInfo<List<ResultBean>>> getObservable() {
                return NetManager.getResponseInfoAPI().getResultDetailList(userId,resultId);
            }
        });
    }

    public static void getExRoutingSheetStepByPage(final String userId, final String billId, final String up, final String stepId, final int pagesize, CallBack<List<RecordListBean>> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<List<RecordListBean>>(callBack) {
            @Override
            protected Observable<ResponseInfo<List<RecordListBean>>> getObservable() {
                return NetManager.getResponseInfoAPI().getExRoutingSheetStepByPage(userId,billId,up,stepId,pagesize);
            }
        });
    }

    public static void getServerVersion(final String s, CallBack<ServerVersion> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<ServerVersion>(callBack) {
            @Override
            protected Observable<ResponseInfo<ServerVersion>> getObservable() {
                return NetManager.getResponseInfoAPI().getServerVersion(s);
            }
        });
    }

    public static void stampNAInfo(final String userId, final String billId, final String stepIds, final String stampUserId, final String stampId, final String naTypeId, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().stampNAInfo(userId,billId,stepIds,stampUserId,stampId,naTypeId);
            }
        });
    }

    public static void getLotDataSheets(final String userId, final String billId, CallBack<LotDataSheet> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<LotDataSheet>(callBack) {
            @Override
            protected Observable<ResponseInfo<LotDataSheet>> getObservable() {
                return NetManager.getResponseInfoAPI().getLotDataSheets(userId,billId);
            }
        });
    }

    public static void saveLotDataSheet(final RequestBody requestBody, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>( callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().saveLotDataSheet(requestBody);
            }
        });
    }

    public static void stampLotDataSheetStep(final String userId, final String billId, final String stepId, final String totalQuantity, final String stampUserId, final String stampId, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().stampLotDataSheetStep(userId,billId,stepId,totalQuantity,stampUserId,stampId);
            }
        });
    }

    public static void getRoutingSheetSubBills(final String userId, final String billId, CallBack<List<DataFilling>> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<List<DataFilling>>(callBack) {
            @Override
            protected Observable<ResponseInfo<List<DataFilling>>> getObservable() {
                return NetManager.getResponseInfoAPI().getRoutingSheetSubBills(userId,billId);
            }
        });
    }

    public static void stampNASubBills(final String userId, final String billId, final String id, final String userId1, final String stampId, final String naTypeId, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().stampNASubBills(userId,billId,id,userId1,stampId,naTypeId);
            }
        });
    }

    public static void getInspectionRecordSheet(final String userId, final String billId, final String subId, CallBack<List<PartCheckInfo>> listCallBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<List<PartCheckInfo>>(listCallBack) {
            @Override
            protected Observable<ResponseInfo<List<PartCheckInfo>>> getObservable() {
                return NetManager.getResponseInfoAPI().getInspectionRecordSheet(userId,billId,subId);
            }
        });
    }

    public static void stampInspectionRecordSheet(final String userId, final String id, final int stampRole, final String actual, final String dispositionId, final String dimAfterRework, final String dimAfterGrind, final String userId1, final String stampId, CallBack<SubPartCheckSealBean> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<SubPartCheckSealBean>(callBack) {
            @Override
            protected Observable<ResponseInfo<SubPartCheckSealBean>> getObservable() {
                return NetManager.getResponseInfoAPI().stampInspectionRecordSheet(userId,id,stampRole,actual,dispositionId,dimAfterRework,dimAfterGrind,userId1,stampId);
            }
        });
    }

    public static void getDispositionList(final String string, CallBack<List<Disposition>> listCallBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<List<Disposition>>(listCallBack) {
            @Override
            protected Observable<ResponseInfo<List<Disposition>>> getObservable() {
                return NetManager.getResponseInfoAPI().getDispositionList(string);
            }
        });
    }

    public static void getBushInstallationSheet(final String userId, final String billId, final String subId, CallBack<List<SubSetInfo>> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<List<SubSetInfo>>(callBack) {
            @Override
            protected Observable<ResponseInfo<List<SubSetInfo>>> getObservable() {
                return NetManager.getResponseInfoAPI().getBushInstallationSheet(userId,billId,subId);
            }
        });
    }

    public static void stampBushInstallationSheet(final String userId, final String id, final String actual, final String outActual, final String innerActual, final String userId1, final String stampId, CallBack<SubSetListSealBean> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<SubSetListSealBean>(callBack) {
            @Override
            protected Observable<ResponseInfo<SubSetListSealBean>> getObservable() {
                return NetManager.getResponseInfoAPI().stampBushInstallationSheet(userId,id,actual,outActual,innerActual,userId1,stampId);
            }
        });
    }

    public static void getBushingSheets(final String userId, final String billId, final String subId, final String o, CallBack<SubProcessListAll> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<SubProcessListAll>(callBack) {
            @Override
            protected Observable<ResponseInfo<SubProcessListAll>> getObservable() {
                return NetManager.getResponseInfoAPI().getBushingSheets(userId,billId,subId,o);
            }
        });
    }

    public static void stampBushingSheetDRS(final RequestBody requestBody, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().stampBushingSheetDRS(requestBody);
            }
        });
    }

    public static void stampBushingSheetStep(final String userId, final String id, final String userId1, final String stampId, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().stampBushingSheetStep(userId,id,userId1,stampId);
            }
        });
    }

    public static void saveBushingSN(final String userId, final String subBillId, final Integer billSeq, final String bushingSN, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().saveBushingSN(userId,subBillId,billSeq,bushingSN);
            }
        });
    }

    public static void saveRoutingSheet(final String userId, final String billId, final String pn, final String partnoId, final String sn, final String actualHour, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().saveRoutingSheet(userId,billId,pn,partnoId,sn,actualHour);
            }
        });
    }

    public static void getEngineerDispositionData(String userId, String woNO, CallBack<List<EngTreatmentInfo>> engTreatmentAllCallBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<List<EngTreatmentInfo>>(engTreatmentAllCallBack) {
            @Override
            protected Observable<ResponseInfo<List<EngTreatmentInfo>>> getObservable() {
                return NetManager.getResponseInfoAPI().getEngineerDispositionData(userId,woNO);
            }
        });
    }

    public static void addEngineerDisposition(RequestBody requestBody, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().addEngineerDisposition(requestBody);
            }
        });
    }

    public static void getUserByCardId(String userId, String billId, String stepId, String msg, CallBack<CardToSeal> cardToSealCallBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<CardToSeal>(cardToSealCallBack) {
            @Override
            protected Observable<ResponseInfo<CardToSeal>> getObservable() {
                return NetManager.getResponseInfoAPI().getUserByCardId(userId,billId,stepId,msg);
            }
        });
    }

    public static void getRoutingSheetStep(String userId, String billId, int billSeq, int scope, int pagenumber, int pagesize, CallBack<MainRepairList> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<MainRepairList>(callBack) {
            @Override
            protected Observable<ResponseInfo<MainRepairList>> getObservable() {
                return NetManager.getResponseInfoAPI().getRoutingSheetStep(userId,billId,billSeq,scope,pagenumber,pagesize);
            }
        });
    }

    public static void removeICRSheet(String userId, String id, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().removeICRSheet(userId,id);
            }
        });
    }

    public static void copyICRSheet(String userId, String id, CallBack<Object> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(callBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().copyICRSheet(userId,id);
            }
        });
    }

    public static void saveICRDisposition(String userId, String id, String trim, String toString, CallBack<Object> objectCallBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(objectCallBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().saveICRDisposition(userId,id,trim,toString);
            }
        });
    }

    public static void stampNAICRSheet(String userId, String id, String userId1, String stampId, String naTypeId, CallBack<Object> objectCallBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(objectCallBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().stampNAICRSheet(userId,id,userId1,stampId,naTypeId);
            }
        });
    }

    public static void transferTechnician(String userId, String stepId, CallBack<Object> objectCallBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(objectCallBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().transferTechnician(userId,stepId);
            }
        });
    }

    public static void saveRoutingSheetArea(String userId, String billId, String trim, CallBack<Object> objectCallBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(objectCallBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().saveRoutingSheetArea(userId,billId,trim);
            }
        });
    }

    public static void effective(String userId, String billId, ArrayList<String> list, CallBack<Object> objectCallBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<Object>(objectCallBack) {
            @Override
            protected Observable<ResponseInfo<Object>> getObservable() {
                return NetManager.getResponseInfoAPI().effective(userId,billId,list);
            }
        });
    }

    public static void getPartsRoutingSheets(String userId, String billId, String bushingSheetId, CallBack<PartsRoutingSheet> callBack) {
        NetManager.getInstance().doSubscribe(new NetManager.Model<PartsRoutingSheet>(callBack) {
            @Override
            protected Observable<ResponseInfo<PartsRoutingSheet>> getObservable() {
                return NetManager.getResponseInfoAPI().getPartsRoutingSheets(userId,billId,bushingSheetId);
            }
        });
    }
}
